//
//  NewOrderDetailHeaderView.m
//  NewPro
//
//  Created by RYX on 2019/4/11.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "NewOrderDetailHeaderView.h"
#import "OrderDetailModel.h"
#import "ShopOrderPosModel.h"

@interface NewOrderDetailHeaderView ()

@property (weak, nonatomic) IBOutlet UIImageView *imgIm;
@property (weak, nonatomic) IBOutlet UILabel *titleLa;
@property (weak, nonatomic) IBOutlet UILabel *priceLa;
@property (weak, nonatomic) IBOutlet UILabel *numLa;
@property (weak, nonatomic) IBOutlet UILabel *desLa;

@property (weak, nonatomic) IBOutlet UILabel *OrderNum;
@property (weak, nonatomic) IBOutlet UILabel *payNum;
@property (weak, nonatomic) IBOutlet UILabel *creatTime;
@property (weak, nonatomic) IBOutlet UILabel *payTime;
//@property (weak, nonatomic) IBOutlet UILabel *yxqLa;
@property (nonatomic,strong) UIView *xibView;

@property (weak, nonatomic) IBOutlet UIView *fhxqView;

@end

@implementation NewOrderDetailHeaderView

- (UIView *)xibView{
    
    if (!_xibView) {
        
        _xibView = [[[NSBundle mainBundle] loadNibNamed:@"NewOrderDetailHeaderView" owner:self options:nil] objectAtIndex:0];
    }
    
    return _xibView;
}

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setUI:frame];

    }
    
    return self;
}

- (void)setUI:(CGRect)frame{
    
    [self addSubview:self.xibView];
    
    self.xibView.frame = frame;
}

-(void)setModel:(OrderDetailModel *)model{
    
    ShopOrderPosModel *smodel = model.shopOrderPosModel;
    [self.imgIm sd_setImageWithURL:[NSURL URLWithString:smodel.imgPath] placeholderImage:nil];
    self.titleLa.text = [NSString stringWithFormat:@"%@",smodel.posName];
    self.priceLa.text = [NSString stringWithFormat:@"¥ %@",smodel.price];
    self.numLa.text = [NSString stringWithFormat:@"X%@",smodel.number];
    self.desLa.text = [NSString stringWithFormat:@"共计%@件商品：¥ %@",smodel.number,model.totalAmount];

    self.creatTime.text = [DateManager changeWithTime:model.gmtCreate];
    self.OrderNum.text = model.payId;
    self.payNum.text = model.paySerial;
    self.payTime.text = [DateManager changeWithTime:model.payDate];
    
    
    if (model.posOrderShipVOList.count <= 0) {
        
        self.fhxqView.hidden = YES;
    }else{
        
        self.fhxqView.hidden = NO;
    }
//    if ([model.logicUntilDay intValue] <= 0) {
//        
//        self.yxqLa.text = @"0天";
//        self.yxqLa.textColor = UIColor.redColor;
//    }else if ([model.logicUntilDay intValue] <= 10){
//        
//        self.yxqLa.text = [NSString stringWithFormat:@"%d天",[model.logicUntilDay intValue]];
//        self.yxqLa.textColor = UIColor.redColor;
//    }else{
//        
//        self.yxqLa.text = [NSString stringWithFormat:@"%d天",[model.logicUntilDay intValue]];
//    }
}

@end
